{{!

  Copyright (c) Meta Platforms, Inc. and affiliates.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

}}{{!

  This template creates a Write method for Thrift typedefs.

  NOTE: use of a function (rather that an instance method) is intentional!
  Typedefs are implemented as Go type aliases (type Foo = Bar) under the hood,
  meaning that all instance methods are "inherited" by the alias (typedef).
  Implementing Write in the form of an instance method may result in a "method
  already declared" compilation error. So instead we must use a uniquely named
  Write function (with no receiver) which takes the alias (typedef) as an argument.

}}
{{#typedef:type}}
func {{typedef:go_qualified_write_func}}(item {{#type:structured?}}*{{/type:structured?}}{{typedef:go_name}}, p thrift.Encoder) error {
    {{> codec/encode}}
    return nil
}
{{/typedef:type}}
{{!newline}}
